using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;

/**
*@file       GWServer_RegisterSender.cs
*@brief      send message GWServer_Register
*
*@author     graywind
*@version    1.0.0.1
*@data       2012/3/23
*/

//send message GWServer_Register
public class msgGWServer_Register
{
    public const int MessageId = (int)GatewayServerTypes.MessageType.GWServer_Register;
    //TODO
	public int SessionId = NetLib.INVALID_SESSION;
	public gatewayserver.ServerInfo MsgContent = new gatewayserver.ServerInfo();
	/// <summary>
	/// Initializes a new instance of the <see cref="msgGWServer_Register"/> class.
	/// </summary>
	/// <param name='session_id'>
	/// Session_id.
	/// </param>
	/// <param name='server_ip'>
	/// Server_ip.
	/// </param>
	/// <param name='server_port'>
	/// Server_port.
	/// </param>
	/// <param name='server_type'>
	/// Server_type.
	/// </param>
	/// <param name='world_group'>
	/// World_group.
	/// </param>
	public msgGWServer_Register(int session_id, string server_ip, int server_port, global.eServerType server_type, int world_group)
	{
		SessionId = session_id;
		MsgContent.IpAddr = server_ip;
		MsgContent.Port = server_port;
		MsgContent.ServerType = server_type;
		MsgContent.WorldGroup = world_group;
	}
	/// <summary>
	/// Initializes a new instance of the <see cref="msgGWServer_Register"/> class.
	/// </summary>
	/// <param name='session_id'>
	/// Session_id.
	/// </param>
	/// <param name='server_ip'>
	/// Server_ip.
	/// </param>
	/// <param name='server_port'>
	/// Server_port.
	/// </param>
	/// <param name='server_type'>
	/// Server_type.
	/// </param>
	public msgGWServer_Register(int session_id, string server_ip, int server_port, global.eServerType server_type)
	{
		SessionId = session_id;
		MsgContent.IpAddr = server_ip;
		MsgContent.Port = server_port;
		MsgContent.ServerType = server_type;
		MsgContent.WorldGroup = GlobalDef.INVALID_WORLD_GROUP;
	}
}

//handle message
public partial class gwMessagePort
{
    /// <summary>
    /// handle message
    /// </summary>
    /// <param name="msg">message wrapper of GWServer_Register</param>
    public static void ProcessMessage(msgGWServer_Register msg)
    {
        //TODO
        //Main Message:  msgGatewayServer
		msgGatewayServer mainMsg = new msgGatewayServer(msg.SessionId, msgGWServer_Register.MessageId, ProtoNet<gatewayserver.ServerInfo>.IntoBytes(msg.MsgContent));
		gwMessagePort.ProcessMessage(mainMsg);
    }
}
